
// 用户相关
export default ({
    namespaced: true,
    state: {
        userInfo: {}, //用户信息
        userPwdForm: {}, //账号信息
        token: null,
        autoLogin: false //自动登录
    },
    mutations: {
        // 修改值
        SET(state, obj) {
            state[obj.key] = obj.value;
        },
        // 修改token
        SET_TOKEN(state, obj) {
            state.token = obj.value;
            if (!obj.token) {
                state.user = {};
            }
        }
    },
    actions: {
        setUser({ commit }, userInfo) {
            commit('SET', { key: 'userInfo', value: userInfo });
        },
        setToken({ commit }, token) {
            commit('SET_TOKEN', { key: 'token', value: token });
        },
    }
})
